package com.yangtao.prototype.system.domain;

import com.yangtao.framework.hibernate.BaseEntity;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

import javax.persistence.*;

/**
 * 用户对应角色
 *
 * @author 杨涛
 */
@Entity
@Table(name = "sys_user_role")
public class UserRole extends BaseEntity {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * 用户角色和用户的关系，为多对一的关系 关系由用户角色表维护
	 */
	@ManyToOne(fetch = FetchType.LAZY, optional = false)
	@JoinColumn(name = "userId")
	@Cascade(CascadeType.SAVE_UPDATE)
	private SysUser user;
	/**
	 * 用户角色和角色的关系，为多对一的关系 关系由用户角色表维护
	 */
	@ManyToOne(fetch = FetchType.LAZY, optional = false)
	@JoinColumn(name = "roleId")
	private Role role;

	/**
	 * @return the user
	 */
	public SysUser getUser() {
		return user;
	}

	/**
	 * @param user the user to set
	 */
	public void setUser(SysUser user) {
		this.user = user;
	}

	/**
	 * @return the role
	 */
	public Role getRole() {
		return role;
	}

	/**
	 * @param role the role to set
	 */
	public void setRole(Role role) {
		this.role = role;
	}
}
